package com.example.demo;

import com.google.protobuf.DescriptorProtos.FileDescriptorProto;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.InvalidProtocolBufferException;

import java.util.*;

public class GrpcDescriptorParser {
    public static void main(String[] args) {
        // 假设我们已经解析了JSON，得到fileDescriptorProtoBase64List
        List<String> fileDescriptorProtoBase64List = new ArrayList<>();
        // 这里填充Base64字符串列表（示例中三个字符串）


//        fileDescriptorProtoBase64List.add("Chp0ZXN0L3Rlcm1pbmFsU2VydmljZS5wcm90bxIQY29tLmV4YW1wbGUuZGVtbxoKaGVhZC5wcm90bzJQCg9UZXJtaW5hbFNlcnZpY2USPQoEYmluZBIZLmNvbS5leGFtcGxlLmRlbW8uUmVxdWVzdBoaLmNvbS5leGFtcGxlLmRlbW8uUmVzcG9uc2VCFAoQY29tLmV4YW1wbGUuZGVtb1ABYgZwcm90bzM=");
//        fileDescriptorProtoBase64List.add("CgpoZWFkLnByb3RvEhBjb20uZXhhbXBsZS5kZW1vGhlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvIi8KCUhlYWRlclJlcRIPCgd0cmFjZUlkGAEgASgJEhEKCXRyYWNlQ29kZRgCIAEoCSIzCglIZWFkZXJSZXMSDAoEY29kZRgBIAEoCRIQCgNtc2cYAiABKAlIAIgBAUIGCgRfbXNnImYKB1JlcXVlc3QSKQoEaGVhZBgBIAEoCzIbLmNvbS5leGFtcGxlLmRlbW8uSGVhZGVyUmVxEicKBGJvZHkYAiABKAsyFC5nb29nbGUucHJvdG9idWYuQW55SACIAQFCBwoFX2JvZHkiZwoIUmVzcG9uc2USKQoEaGVhZBgBIAEoCzIbLmNvbS5leGFtcGxlLmRlbW8uSGVhZGVyUmVzEicKBGJvZHkYAiABKAsyFC5nb29nbGUucHJvdG9idWYuQW55SACIAQFCBwoFX2JvZHlCFAoQY29tLmV4YW1wbGUuZGVtb1ABYgZwcm90bzM=");
//        fileDescriptorProtoBase64List.add("Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3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SDgoGcmVzTXNnGAIgASgJQhgKFGNuLmVlZXBheS5oa01lcmNoYW50UAFiBnByb3RvMw==");

        // 步骤1：解码每个Base64字符串并解析为FileDescriptorProto
        List<FileDescriptorProto> fileDescriptorProtos = new ArrayList<>();
        Base64.Decoder base64Decoder = Base64.getDecoder();
        for (String base64Str : fileDescriptorProtoBase64List) {
            byte[] data = base64Decoder.decode(base64Str);
            try {
                FileDescriptorProto fileDescriptorProto = FileDescriptorProto.parseFrom(data);
                fileDescriptorProtos.add(fileDescriptorProto);
            } catch (InvalidProtocolBufferException e) {
                e.printStackTrace();
            }
        }

        // 步骤2：构建FileDescriptor映射
        Map<String, FileDescriptor> fileDescriptorMap = new HashMap<>();
        // 用于记录是否成功构建的标记
        boolean changed;
        do {
            changed = false;
            for (FileDescriptorProto proto : fileDescriptorProtos) {
                String fileName = proto.getName();
                // 如果已经构建过，跳过
                if (fileDescriptorMap.containsKey(fileName)) {
                    continue;
                }
                // 获取该文件的依赖项
                List<String> dependencies = proto.getDependencyList();
                List<FileDescriptor> deps = new ArrayList<>();
                boolean allDepsResolved = true;
                for (String dep : dependencies) {
                    FileDescriptor depDesc = fileDescriptorMap.get(dep);
                    if (depDesc == null) {
                        allDepsResolved = false;
                        break;
                    }
                    deps.add(depDesc);
                }
                if (allDepsResolved) {
                    try {
                        FileDescriptor fileDescriptor = FileDescriptor.buildFrom(proto, deps.toArray(new FileDescriptor[0]));
                        fileDescriptorMap.put(fileName, fileDescriptor);
                        changed = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } while (changed && fileDescriptorMap.size() < fileDescriptorProtos.size());

        // 检查是否所有文件都构建成功
        if (fileDescriptorMap.size() != fileDescriptorProtos.size()) {
            System.err.println("Some file descriptors failed to build.");
        }

        // 现在我们有了所有文件的描述符，我们可以遍历它们获取服务定义
        for (FileDescriptor fileDescriptor : fileDescriptorMap.values()) {
            System.out.println("File: " + fileDescriptor.getName());
            for (com.google.protobuf.Descriptors.ServiceDescriptor service : fileDescriptor.getServices()) {
                System.out.println("  Service: " + service.getFullName());
                for (com.google.protobuf.Descriptors.MethodDescriptor method : service.getMethods()) {
                    System.out.println("    Method: " + method.getName());
                    System.out.println("      Input: " + method.getInputType().getFullName());
                    System.out.println("      Output: " + method.getOutputType().getFullName());
                }
            }
        }
    }
}
